﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;

using System.Text;
using System.Windows.Forms;
namespace CommonTools
{
    public partial class UpperCaseComboBox : ComboBox
    {
        public UpperCaseComboBox()
        {
            InitializeComponent();
            this.KeyPress += new KeyPressEventHandler(UpperCaseComboBox_KeyPress);
            this.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            this.AutoCompleteSource = AutoCompleteSource.ListItems;
        }

        void UpperCaseComboBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            char c = e.KeyChar;
            if (c >= 'a' && c <= 'z')
            {
                int digit = (int)c;
                digit = digit - 'a' + 'A';
                e.KeyChar = Convert.ToChar(digit);
            }
        }

        public UpperCaseComboBox(IContainer container)
        {
            container.Add(this);
            InitializeComponent();
            this.KeyPress += new KeyPressEventHandler(UpperCaseComboBox_KeyPress);
        }
        
    }
}
